*******************************
* Table A2 
*******************************
clear
use masterdata_county.dta

encode state, gen(state2)
gen repratio08 = gop_2008/(dem_2008 + gop_2008)
gen repratio12 = gop_2012/(dem_2012 + gop_2012)
gen repratio16 = gop_2016/(dem_2016 + gop_2016)

gen lntotaffected = ln(totaffected +1)
gen lntotaffected_app = ln(totaffected_approved +1)
gen lntotaffected_den = ln(totaffected_denied +1)

gen taaworkforce = totaffected/civilian
gen taaworkforce_app = totaffected_approved/civilian
gen taaworkforce_denied = totaffected_denied/civilian

gen lntaaworkforce = ln(taaworkforce +1)

gen certifyratio = totaltaa_certified/totaltaa
replace certifyratio = 0 if certifyratio ==.

gen approvedratio = totaffected_approved/totaffected

gen repchange1 = (repratio16 - repratio08)*100
gen repchange2 = (repratio16 - repratio12)*100

eststo clear
eststo: quietly areg rep_primary_trump_vs totaltaa certifyratio,      a(state2) vce(cluster state2)
eststo: quietly areg rep_primary_trump_vs totaltaa lntotaffected_app, a(state2) vce(cluster state2)
eststo: quietly areg repchange1           totaltaa certifyratio,      a(state2) vce(cluster state2)
eststo: quietly areg repchange1           totaltaa lntotaffected_app, a(state2) vce(cluster state2)
eststo: quietly areg repchange2           totaltaa certifyratio,      a(state2) vce(cluster state2)
eststo: quietly areg repchange2           totaltaa lntotaffected_app, a(state2) vce(cluster state2)
esttab, star(* 0.1 ** 0.05 *** 0.01) ar2
